package com.imy.luascript.base.activity;

import android.os.Bundle;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;

import com.imy.luascript.R;
import com.imy.luascript.base.view.Toolbar;
import com.imy.luascript.helper.systembar.SystemBarHelper;
import com.imy.luascript.utils.StatusBarUtil;
import com.imy.luascript.utils.ToolBarBuilder;
import com.imy.luascript.viewmodel.BaseViewModel;

/**
 * @ProjectName: frame
 * @Package: com.imy.frame.activity
 * @ClassName: BaseViewActivity
 * @Description: 描述
 * @Author: Imy
 * @CreateDate: 2020/10/26 16:33
 */
public abstract class BaseViewActivity<V extends BaseViewModel> extends BaseActivity<V>  {

    protected Toolbar toolbar;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        hideStatusBar();
    }

    private void hideStatusBar() {
        //先隐藏系统状态栏
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        SystemBarHelper.setStatusBarMode(this, true);
        SystemBarHelper.tintStatusBar(this, getResources().getColor(R.color.white));


    }

    public void setToolbarTitle(String title) {
        toolbar.setTitle(title);
    }


    public void setToolbarTitle(int res) {
        toolbar.setTitle(getString(res));
    }

    @Override
    protected ToolBarBuilder getToolBarBuilder() {
        ToolBarBuilder.Builder builder = new ToolBarBuilder.Builder();
        builder.setHasToolbar(true);
        toolbar = new Toolbar(self);
        toolbar.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        builder.setView(toolbar);
        return builder.build();
    }
}